var columns = [
    {field: 'id',title: '序号',
        formatter:function(value, row, index){
            return index + 1 + (row.pageNumber-1)*row.pageSize;
        }
    },
    //{field: 'id',title: 'ID'},
    {field: 'orgId',title:'组织机构ID'},
    {field: 'subscriber',title: '预约名称'},
    {field: 'lessonName',title: '课程名称'},
    {field: 'lessonScheduleName',title: '课时'},
    {field: 'dealPersonName',title: '处理人'},
    {field: 'orgName',title: '组织名称'},
    {field: 'trueName',title: '用户名称'},
    {field: 'lessonId',title: '课程ID'},
    {field: 'lessonScheduleId',title: '课时ID'},
    {field: 'userId',title: '用户ID'},
    {field: 'approverId',title: '处理人ID'},
    {field: 'reservationDate',title: '预约时间'},
    {
        field: 'state',
        title: '处理状态',
        align: 'center',
        formatter: function (value, row, index) {
            return pubSwitch.getSwitchBtnCss(row);
        }
    },
    {field: 'operator',title: '操作',
        formatter: function (value, row, index) {
            var html='';
            html += '<button class="btn btn-warning btn-icon-anim btn-circle" style="width: 20px;height: 20px;" onclick=\'appointment.showSAppointmentPage("'+row.id+'")\' title="查看">' +
                '<i class="fa fa-eye"></i></button>';
            return html;
        }
    }];

var appointment={
    init:function() {
        var orgId  = $("#orgId").val();
        var lessonId = $("#lessonId").val();
        var userId = $("#userId").val();
        var lessonScheduleId = $("#lessonScheduleId").val();
        var approverId = $("#approverId").val();
        var startTime = $("#startTime").val();
        var endTime = $("#endTime").val();
        var parmsObj = {};
        parmsObj.orgId=orgId;
        parmsObj.userId=userId;
        parmsObj.lessonId=lessonId;
        parmsObj.lessonScheduleId=lessonScheduleId;
        parmsObj.approverId=approverId;
        parmsObj.startTime=startTime;
        parmsObj.endTime=endTime;
        pubForm.getBootTableSwitch("#tableAppointmentList","/base/appointment/queryAppointmentList?orgId="+orgId+"&userId="+userId+"&lessonId="+lessonId+"&startTime="+startTime+"&endTime="+endTime+"&lessonScheduleId="+lessonScheduleId+"&approverId="+approverId,"/base/switch/updateState",parmsObj,"t_appointment");
    },
    refreshTabel:function () {
        var size = $(".page-size").text();
        var orgId  = $("#orgId").val();
        var lessonId = $("#lessonId").val();
        var userId = $("#userId").val();
        var lessonScheduleId = $("#lessonScheduleId").val();
        var approverId = $("#approverId").val();
        var startTime = $("#startTime").val();
        var endTime = $("#endTime").val();
        var opt = {
            url: application.contextPath + "/base/appointment/queryAppointmentList",
            query: {
                size: size,
                page: 1,
                orgId:orgId,
                lessonId:lessonId,
                lessonScheduleId:lessonScheduleId,
                userId:userId,
                approverId:approverId,
                startTime:startTime,
                endTime:endTime
            },
            silent: true
        };
        $("#tableAppointmentList").bootstrapTable('refreshOptions',opt);
    },
    showSAppointmentPage:function(id){
        loadUtil = new Load($);
        loadUtil.load({
            container:'#homeContent',
            url: application.contextPath+"/base/appointment/showSAppointmentPage?id="+id
        });
    },
    queryAppointmentByMap:function () {
        var data = {};
        var size = $(".page-size").text();
        var orgId  = $("#orgId").val();
        var lessonId = $("#lessonId").val();
        var userId = $("#userId").val();
        var lessonScheduleId = $("#lessonScheduleId").val();
        var approverId = $("#approverId").val();
        var startTime = $("#startTime").val();
        var endTime = $("#endTime").val();

        var opt = {
            url: application.contextPath + "/base/appointment/queryAppointmentList?orgId="+orgId+"&userId="+userId+"&lessonId="+lessonId+"&startTime="+startTime+"&endTime="+endTime+"&lessonScheduleId="+lessonScheduleId+"&approverId="+approverId,
            query: {
                size: size,
                page: 1
            },
            silent: true
        };
        $('#tableAppointmentList').bootstrapTable('refreshOptions', opt);

    }
};

$(document).ready(function(){
    appointment.init();
});